home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Documents / JAVA Programming / examples / 17 / Scribble1.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-09-08  |  1.6 KB  |  59 lines

  1. import java.applet.Applet;
  2. import java.awt.Button;
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Event;
  7. import java.awt.Graphics;
  8.  
  9. public class Scribble1 extends Applet {
  10.    private int lastx;
  11.    private int lasty;
  12.    Button clear_button;
  13.    // $FF: renamed from: g java.awt.Graphics
  14.    Graphics field_0;
  15.  
  16.    public void init() {
  17.       this.clear_button = new Button("Clear");
  18.       ((Container)this).add(this.clear_button);
  19.       this.field_0 = ((Component)this).getGraphics();
  20.    }
  21.  
  22.    public boolean mouseDown(Event var1, int var2, int var3) {
  23.       this.lastx = var2;
  24.       this.lasty = var3;
  25.       return true;
  26.    }
  27.  
  28.    public boolean mouseDrag(Event var1, int var2, int var3) {
  29.       this.field_0.setColor(Color.black);
  30.       this.field_0.drawLine(this.lastx, this.lasty, var2, var3);
  31.       this.lastx = var2;
  32.       this.lasty = var3;
  33.       return true;
  34.    }
  35.  
  36.    public boolean keyDown(Event var1, int var2) {
  37.       if (var1.id == 401 && var2 == 1073) {
  38.          this.clear();
  39.          return true;
  40.       } else {
  41.          return false;
  42.       }
  43.    }
  44.  
  45.    public boolean action(Event var1, Object var2) {
  46.       if (var1.target == this.clear_button) {
  47.          this.clear();
  48.          return true;
  49.       } else {
  50.          return false;
  51.       }
  52.    }
  53.  
  54.    public void clear() {
  55.       this.field_0.setColor(((Component)this).getBackground());
  56.       this.field_0.fillRect(0, 0, ((Component)this).bounds().width, ((Component)this).bounds().height);
  57.    }
  58. }
  59.